<template>
    <Modal
            class-name="vertical-center-modal"
            v-model="modal"
            :width="80"
            :title="head_title">
        <div v-if="modal" class="row">
            <div class="col-lg-12">
                <div class="card ">
                    <Form ref="formValidate" :model="info" action="javascript:void(0)">
                        <div class="row">
                            <div class="col-md-6">
                                <FormItem>
                                    <div class="row">
                                        <label slot='label' class="control-label text-right col-md-3">入驻宾馆</label>
                                        <div class="col-md-9">
                                            <Input v-model="info.hotel" placeholder="请输入入驻宾馆"/>
                                        </div>
                                    </div>
                                </FormItem>
                                <FormItem>
                                    <div class="row">
                                        <label slot='label' class="control-label text-right col-md-3">房间号</label>
                                        <div class="col-md-9">
                                            <Input v-model="info.room_no" placeholder="请输入房间号"/>
                                        </div>
                                    </div>
                                </FormItem>
                                <FormItem>
                                    <div class="row">
                                        <label slot='label' class="control-label text-right col-md-3">入住时间</label>
                                        <div class="col-md-9">
                                            <Input v-model="info.check_in_at" placeholder="请输入入住时间"/>
                                        </div>
                                    </div>
                                </FormItem>
                                <FormItem>
                                    <div class="row">
                                        <label slot='label' class="control-label text-right col-md-3">退房时间</label>
                                        <div class="col-md-9">
                                            <Input v-model="info.check_out_at" placeholder="请输入退房时间"/>
                                        </div>
                                    </div>
                                </FormItem>
                            </div>
                            <!--<div class="col-md-12">
                                <hr/>
                                <h4>参见会议</h4>
                                <i-checkbox-group v-model="conference">
                                    <i-checkbox v-for="item in info.mee_list" :key="item.id" :label="item.id">{{item.title}}</i-checkbox>
                                </i-checkbox-group>
                            </div>-->
                        </div>
                    </Form>
                </div>
            </div>
        </div>
        <div slot="footer">
            <button class="btn btn-danger" type="button" @click='cancel'>取消</Button>
            <btn-submit class="btn btn-success" type="submit" :p-click="ok">确定</btn-submit>
        </div>
    </Modal>
</template>
<script>
    import serWorkerHotel from '../../serves/api-worker-hotel'
    const setDataDef = {
        id:'',
        // arrive_no:'',
        // arrive_at:'',
        // leave_at:'',
        // leave_no:'',
        // is_vip_port:'',
        // cart_no:'',
        hotel:'',
        room_no:'',
        check_in_at:'',
        check_out_at:'',
        // need_pt:'',
        // status:'',
        // zhuangtai:'',
    };
    export default{
        props:{

        },
        data () {
            return {
                modal:false,
                type:'',
                conference:[],
                info:{},
            }
        },
        computed:{
            head_title(){
                return this.type == 'edit' ? '更新陪同参会人员信息':'添加陪同参会人员信息'
            },
        },
        methods: {
            async handleOpen(data){
                this.$set(this,'type',data._type?'edit':'add');
                let res = await serCustomer.detail({
                    id:data.id
                });
                this.info = Object.assign({},setDataDef,res.data||{});
                var a = [];
                this.info.mee_list.forEach((v,i)=>{
                    if(v.join==1){a.push(v.id)}
                });
                this.$set(this,'conference',a);
                this.$set(this,'modal',true);
            },
            cancel () {
                this.$emit('on-change',false);
                this.$set(this,'modal',false);
            },
            searchSelectNeed (value) {
                this.$set(this.info,'need_pt',value);
            },
           /* searchSelectStatus (value) {
                this.$set(this.info,'status',value);
            },*/
            timeChange (value,key) {
                this.$set(this.info,key,value);
            },

            async ok () {
                let url = 'add';
                let data = {
                    // arrive_no:this.info.arrive_no,
                    // arrive_at:this.info.arrive_at,
                    // leave_at:this.info.leave_at,
                    // leave_no:this.info.leave_no,
                    // is_vip_port:this.info.is_vip_port,
                    // cart_no:this.info.cart_no,
                    hotel:this.info.hotel,
                    room_no:this.info.room_no,
                    check_in_at:this.info.check_in_at,
                    check_out_at:this.info.check_out_at,
                    // need_pt:this.info.need_pt,
                    // mee_ids:this.conference,
                    // status:this.info.status,
                    // zhuangtai:this.info.zhuangtai,
                };
                if(this.type=='edit'){
                    url = 'customerSave';
                    data.id = this.info.id;
                }
                let res = await serWorkerHotel[url](data);
                if(res.code==1){
                    this.$Message.success(res.message);
                    this.$emit('on-change',true);
                    this.$set(this,'modal',false);
                    return true;
                }else{
                    this.$Message.error(res.message);
                    return false;
                }
            },
        },
        components:{
        }
    }
</script>